/*
 * Copyright (C) 2019 ~ 2022 Uniontech Technology Co., Ltd.
 *
 * Author:     zhangbingyi <zhangbingyi@uniontech.com>
 *
 * Maintainer: zhangbingyi <zhangbingyi@uniontech.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef PERIPHERALSMANAGEMENTMODEL_H
#define PERIPHERALSMANAGEMENTMODEL_H

#include "common.h"
#include "peripheralsrevertdialog.h"

#include <QObject>

class DBusInvokerInterface;
class PeripheralsManagementModel : public QObject
{
    Q_OBJECT
public:
    explicit PeripheralsManagementModel(QObject *parent = nullptr);

    // 外设管控状态设置
    void setPeripheralsStatus(SettingType type, bool open);

    bool getPeripheralsKey(const QString &key);
    void setPeripheralsKey(const QString &key, bool status);

public Q_SLOTS:
    void acceptSetPeripheralsPermssonResult(int type, bool open, int result);
    void onCurrentEngineValueChanged(const QString &key, const QDBusVariant &value);

    void peripheralsRevertDialogClose();
    void peripheralsRevertDialogSendPeripheralsRevert();
    void peripheralsRevertDialogClosed();
Q_SIGNALS:
    // 发送恢复原状信号
    void notifyPeripheralsRevert();
    // 同步外设管理状态
    void synPeripheralsStatus(const QString &key, bool open);

private:
    // 系统服务
    DBusInvokerInterface *m_rootMonitorDBusInter;
    // 等保系统服务
    DBusInvokerInterface *m_peripheralsDBusInter;

    PeripheralsRevertDialog *m_peripheralsRevertDialog;

    bool m_isFlag;
};

#endif // PERIPHERALSMANAGEMENTMODEL_H
